import axios from "axios";
import { useEffect, useState } from "react";

function useRequest(url: string) {
  const [response, setResponse] = useState([]);

  useEffect(() => {
    async function fetchData() {
      const res = await axios.get(url);
      setResponse(res.data);
    }
    fetchData();
  }, [url]);

  return {
    response,
    setResponse,
  };
}

export default useRequest;
